package com.cooper.controllers.seller;


import org.springframework.beans.factory.annotation.Autowired;

import com.cooper.constants.DisTypeConstants;
import com.cooper.controllers.Controller;
import com.cooper.core.MinasPropertyHandler;
import com.cooper.entity.BrandBaseEntity;
import com.cooper.entity.DisplayPicConfigListDo;
import com.cooper.pagination.PageInfo;
import com.cooper.pagination.PageResult;
import com.cooper.service.admin.DisplayPicConfigService;
import com.cooper.vo.DisplayPicConfigVo;

import net.paoding.rose.web.Invocation;
import net.paoding.rose.web.annotation.rest.Get;
import net.paoding.rose.web.portal.Portal;

public class InsellerController extends Controller {

	@Autowired
	private DisplayPicConfigService displayPicConfigService;
	
	@Autowired
	private MinasPropertyHandler minasPropertyHandler;
	
	@Get
	public String execute(Invocation inv,Portal portal) throws Exception{
		DisplayPicConfigVo queryParamVo = new DisplayPicConfigVo();
		queryParamVo.setStatus(DisplayPicConfigListDo.DISPLAY_YES);
		queryParamVo.setDisType(DisTypeConstants.INSELLER_STYLE);
		PageInfo pageInfo = new PageInfo();
		pageInfo.setPageSize(4);
		PageResult<DisplayPicConfigVo> styleData = this.displayPicConfigService.queryDisplayPicConfigPage(queryParamVo, pageInfo);
		inv.addModel("styleList", styleData.getResult());
		return "inseller";
	}
	
	@Get("designersList")
	public Object designersList(Invocation inv,BrandBaseEntity brand){
		StringBuffer buf = new StringBuffer();
		try{
			DisplayPicConfigVo queryParamVo = new DisplayPicConfigVo();
			queryParamVo.setStatus(DisplayPicConfigListDo.DISPLAY_YES);
			queryParamVo.setDisType(DisTypeConstants.INSELLER_DESIGNER);
			PageInfo pageInfo = new PageInfo();
			pageInfo.setPageIndex(1);
			pageInfo.setPageSize(6);
			PageResult<DisplayPicConfigVo> ret = this.displayPicConfigService.queryDisplayPicConfigPage(queryParamVo, pageInfo);
			if(ret!=null&&ret.getResult().size()>0){
				for(int i=0;i<ret.getResult().size();i++){
			    	 //buf.append("<div class='item'>" );
			    	 buf.append("<a href='#' class='item'><img src="+this.minasPropertyHandler.getFileServer()+"download/"+ret.getResult().get(i).getFileId()+" alt=''"+"></a>");
			    	 //buf.append("</div>" );
				}
			}
		}catch(Exception e){
			logger.error("InsellerController-designersList-error",e);
		}
		return "@"+buf.toString();
	}
		
}
